package com.nagat.ejb.test;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

import com.nagat.ejb.entity.Emp;


public final class EntityUtil {

	public final static void print(Object obj){
		
		
		Class c = obj.getClass();
		
		Field fs[] = c.getFields();
		
		System.out.println(fs.length);
		
		for(Field f : fs){
			try {
				System.out.println(123);
				System.out.println(f.getName()+" : "+c.getMethod("get"+f.getName().substring(0,1).toUpperCase()+f.getName().substring(1)).invoke(null));
			} catch (IllegalArgumentException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SecurityException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (NoSuchMethodException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}
	
	public static void main(String[] args) {
		
		Emp e = new Emp();
		e.setEmpno(10);
		
		EntityUtil.print(e);
	}
}
